package cn.edu.sdjzu.xg.eagle.bysj.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import cn.edu.sdjzu.xg.eagle.bysj.annotation.IgnoreAuth;
import cn.edu.sdjzu.xg.eagle.bysj.annotation.SysLog;
import cn.edu.sdjzu.xg.eagle.bysj.entity.HuiyishileixingEntity;
import cn.edu.sdjzu.xg.eagle.bysj.entity.view.HuiyishileixingView;
import cn.edu.sdjzu.xg.eagle.bysj.service.Interface.HuiyishileixingService;
import cn.edu.sdjzu.xg.eagle.bysj.utils.MPUtil;
import cn.edu.sdjzu.xg.eagle.bysj.utils.PageUtils;
import cn.edu.sdjzu.xg.eagle.bysj.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Map;

/**
 * 会议室类型
 * 后端接口
 * @author 
 * @email 
 * @date 2025-06-02 13:29:28
 */
@RestController
@RequestMapping("/huiyishileixing")
public class HuiyishileixingController {
    @Autowired
    private HuiyishileixingService huiyishileixingService;









    /**
     * 后台列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,HuiyishileixingEntity huiyishileixing,
                                            HttpServletRequest request){
                                    EntityWrapper<HuiyishileixingEntity> ew = new EntityWrapper<HuiyishileixingEntity>();
                                                        
        
        
        PageUtils page = huiyishileixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huiyishileixing), params), params));
        return R.ok().put("data", page);
    }







    /**
     * 前端列表
     */
	@IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,HuiyishileixingEntity huiyishileixing,
		HttpServletRequest request){
        EntityWrapper<HuiyishileixingEntity> ew = new EntityWrapper<HuiyishileixingEntity>();

		PageUtils page = huiyishileixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huiyishileixing), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( HuiyishileixingEntity huiyishileixing){
       	EntityWrapper<HuiyishileixingEntity> ew = new EntityWrapper<HuiyishileixingEntity>();
      	ew.allEq(MPUtil.allEQMapPre( huiyishileixing, MPUtil.camelToSnake("huiyishileixing")));
        return R.ok().put("data", huiyishileixingService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(HuiyishileixingEntity huiyishileixing){
        EntityWrapper< HuiyishileixingEntity> ew = new EntityWrapper< HuiyishileixingEntity>();
 		ew.allEq(MPUtil.allEQMapPre( huiyishileixing, MPUtil.camelToSnake("huiyishileixing")));
		HuiyishileixingView huiyishileixingView =  huiyishileixingService.selectView(ew);
		return R.ok("查询会议室类型成功").put("data", huiyishileixingView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        HuiyishileixingEntity huiyishileixing = huiyishileixingService.selectById(id);
		huiyishileixing = huiyishileixingService.selectView(new EntityWrapper<HuiyishileixingEntity>().eq("id", id));
        return R.ok().put("data", huiyishileixing);
    }

    /**
     * 前端详情
     */
	@IgnoreAuth
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        HuiyishileixingEntity huiyishileixing = huiyishileixingService.selectById(id);
		huiyishileixing = huiyishileixingService.selectView(new EntityWrapper<HuiyishileixingEntity>().eq("id", id));
        return R.ok().put("data", huiyishileixing);
    }
    



    /**
     * 后端保存
     */
    @RequestMapping("/save")
    @SysLog("新增会议室类型")
    public R save(@RequestBody HuiyishileixingEntity huiyishileixing, HttpServletRequest request){
    	//ValidatorUtils.validateEntity(huiyishileixing);
        huiyishileixingService.insert(huiyishileixing);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @SysLog("新增会议室类型")
    @RequestMapping("/add")
    public R add(@RequestBody HuiyishileixingEntity huiyishileixing, HttpServletRequest request){
    	//ValidatorUtils.validateEntity(huiyishileixing);
        huiyishileixingService.insert(huiyishileixing);
        return R.ok();
    }



    /**
     * 修改
     */
    @RequestMapping("/update")
    @Transactional
    @SysLog("修改会议室类型")
    public R update(@RequestBody HuiyishileixingEntity huiyishileixing, HttpServletRequest request){
        //ValidatorUtils.validateEntity(huiyishileixing);
        huiyishileixingService.updateById(huiyishileixing);//全部更新
        return R.ok();
    }



    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @SysLog("删除会议室类型")
    public R delete(@RequestBody Long[] ids){
        huiyishileixingService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}